torchao: safetensors save/load + disk group offload (closes #13713)#13721
Open
itzzdeep wants to merge 1 commit into
Open
torchao: safetensors save/load + disk group offload (closes #13713)#13721itzzdeep wants to merge 1 commit into
itzzdeep wants to merge 1 commit into
Conversation
Member
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Fixes #13713
Description
Adds safetensors save/load and disk-based group offloading for TorchAO-quantized models. Implemented via 4 no-op hooks on
DiffusersQuantizer, overridden byTorchAoHfQuantizer:get_state_dict_and_metadata— flatten subclasses on saveset_metadata— read torchao header from each shard on loadupdate_loaded_keys— collapse_weight_*suffixes to canonical namesupdate_state_dict_with_metadata— per-shard unflatten with cross-shard bufferGroup offload reuses the same path. No torchao-specific code in
modeling_utils. Requires torchao ≥ 0.15.0 andversion=2configs; v1 raises aValueErrornaming the fix.Results
End-to-end verified on Lumina-Image-2.0 (2.61B params, A100, Int8 weight-only).
Save → reload is bit-perfect (cosine_dist = 0.0). Forward latency cost: 87 ms → 1592 ms.
Tests
TorchAoSerializationTest7/7 +test_group_offloading.py38/38 pass. Real Flux.1-Dev save/reload works; disk group offload on Flux is blocked by pre-existing torchao bugs[x] Did you write any new necessary tests?
Added
test_safetensors_save_int_a16w8andtest_group_offload_to_disk_int_a16w8intests/quantization/torchao/test_torchao.pyWho can review?
Anyone in the community is free to review the PR once the tests have passed. Feel free to tag
members/contributors who may be interested in your PR.
@sayakpaul